package com.ghosthigh.simpleaccount.client;

import java.util.List;

import com.ghosthigh.simpleaccount.client.common.HeaderPresenter;
import com.ghosthigh.simpleaccount.client.common.HeaderView;
import com.ghosthigh.simpleaccount.client.common.HeaderViewImpl;
import com.ghosthigh.simpleaccount.client.common.Presenter;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class UserServiceController implements Presenter, ValueChangeHandler<String> {

  private HandlerManager eventBus;
  private VerticalPanel verticalLayoutPanel;
  private DockPanel contentPanel;

  private HeaderPresenter headerPresenter;
  private HeaderView<List<String>> headerView;
  private SimplePanel headerContainer;


  public UserServiceController(HandlerManager eventBus) {
    this.eventBus = eventBus;
    initLayout();
  }

  private void initLayout() {
    verticalLayoutPanel = new VerticalPanel();
    verticalLayoutPanel.setWidth("100%");
    headerContainer = new SimplePanel();
    contentPanel = new DockPanel();
    headerContainer.setWidth("100%");
    verticalLayoutPanel.add(headerContainer);
    verticalLayoutPanel.add(contentPanel);
  }

  @Override
  public void go(HasWidgets container) {
    container.add(verticalLayoutPanel);
    initHeader();
    // TODO: contentPart

  }

  protected void initHeader() {
    headerView = new HeaderViewImpl<List<String>>();
    headerPresenter = new HeaderPresenter(headerView);
    headerPresenter.go(headerContainer);
  }

  @Override
  public void onValueChange(ValueChangeEvent<String> event) {
  }
}
